feat(client): connection resilience - jittered reconnect backoff, idempotency-safe replay, and fault visibility#77
Merged
Conversation
4bfc3af to
1d3bcc1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Hardens client (and one server) connection resilience so transient failures are handled predictably instead of turning into busy-loops, silent data loss, duplicate side effects, or hung callers. Five related changes:
Details
Reconnect backoff (feat)
New
ReconnectBackoff.Computecentralizes exponential-backoff-with-jitter so HTTP/1.x (ReconnectPolicy), HTTP/2 & HTTP/3 state machines, andClientStreamOwnerall space their retries identically. The first attempt after a real disconnect still fires immediately; only subsequent retries are deferred behind areconnect-backofftimer. Spacing avoids hammering a connection-refused peer in a tight loop; jitter avoids a thundering herd of correlated reconnects.New, fully-defaulted knobs on the client options:
ReconnectInitialBackoff(default 100 ms),ReconnectMaxBackoff(5 s),ReconnectBackoffMultiplier(2.0),ReconnectBackoffJitter(±20%)StreamRetryBackoffJitter(±20%) for stream re-materializationIdempotency-safe replay & deterministic teardown (fix)
POST) are **failed rather than replayed*ve processed them, so a replay risks aduplicate side effect (RFC 9110 §9.2.2). Applied consistently to H1.1, H2, and H3.request.Failis idempotent, so streams that already delivered a response are unaffected.### Content-decode failures (fix)
A corrupt or truncated compressed response body (
Content-Encoding: gzip/…) now throws a clearHttpRequestException("compressed data is corrupt or truncated") instead of silently returning a truncated body. Typed asHttpRequestExceptionsoHttpContent's stream-copy wrapping passes it through unwrapped.Server handler crashes (fix)
ApplicationBridgeStageno longer lets ann vanish: it reaches context disposal(OnDispose(context, exception)), emits a 500, and is traced — so operators can observe handler crashes. Crashes during context creation (before an `AppConed via tracing.Housekeeping (chore)
Removed the obsolete
WireBufferwrapper-pool test hook and bumpedservus.akka.Testing
New/expanded specs cover each change: recoolicy scheduling,idempotent-vs-non-idempotent replay, teardown-fails-buffered/in-flight requests across H1.1/H2/H3, corrupt-gzip decode surfacing, and handler-crash disposeen.